BIN_DIR=$(CURDIR)/bin
LIB_DIR=$(CURDIR)/lib
INCLUDE_DIR=$(CURDIR)/include
BIN_FILES= backup_interface backup_judge \
			oj_demo

redisClient: redisClient/redisClient.go
	cd redisClient && go mod tidy -compat=1.17 && go build redisClient.go

backup_interface: backup_interface/backup_interface.go redisClient 
	cd $@ && go mod tidy -compat=1.17 && go build backup_interface.go

backup_judge: install_libjudge backup_judge/backup_judge.go redisClient
	cd $@ && go mod tidy -compat=1.17 && go build backup_judge.go

oj_demo: oj_demo/oj_demo.go
	cd $@ && go mod tidy -compat=1.17 && go build oj_demo.go

libjudge:
	make -C libjudge/src libjudge

run_test:
	make -C libjudge/src run_test

run_judge:
	make -C libjudge/src run_judge

install_libjudge: libjudge
	mkdir -p $(LIB_DIR)
	mkdir -p $(INCLUDE_DIR)
	cp ./libjudge/src/judge.h $(INCLUDE_DIR)/judge.h
	cp ./libjudge/src/options.h $(INCLUDE_DIR)/options.h
	cp ./libjudge/src/libjudge.so $(LIB_DIR)/libjudge.so

clean:
	make -C libjudge clean

.PHONY:clean all libjudge install_libjudge $(BIN_FILES)